package com.molyfun.parents.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

import com.molyfun.parents.impl.ScrollViewListener;

/**
 * Created by william(liuchao.hit@gmail.com).
 * Date:05/03/2018.
 */

public class ObservableScrollView extends ScrollView {


    private ScrollViewListener mScrollViewListener;

    public void setScrollViewListener(ScrollViewListener scrollViewListener) {
        this.mScrollViewListener = scrollViewListener;
    }

    public ObservableScrollView(Context context) {
        super(context);
    }

    public ObservableScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ObservableScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        System.out.println("----l>" + x);
        System.out.println("----t>" + y);
        System.out.println("----mScrollViewListener>" + mScrollViewListener == null);


        if (mScrollViewListener != null) {
            mScrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
        }
        super.onScrollChanged(x, y, oldx, oldy);
    }
}